package handler

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"post-hub/internal/dto"
	"post-hub/internal/model"
	"post-hub/response"
)

func UpdatePost(c *gin.Context) {

	var post model.Post
	err := c.ShouldBind(&post)
	if err != nil {
		response.Error(c, "解析失败")
		return
	}
	post = model.Post{
		Model: gorm.Model{
			ID: post.ID,
		},
		Status: "审核成功",
	}
	err = dto.UpdatePost(&post, int(post.ID))
	if err != nil {
		response.Error(c, "修改失败")
		return
	}
	response.Success(c, "修改成功", post.Status)
}
